package edu.bbu.commonproject.desktop.gui.view.swing.setup.menus;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

import edu.bbu.commonproject.desktop.gui.view.swing.utils.Design;

/**
 * The synchronize setup panel class.
 */
public class SyncSetupsPanel extends JPanel
{
	/** The base image. */
	private Image baseImage;
	
	/** The one way synchronize explain. */
	private JLabel oneWaySyncExplain;
	
	/** The two way synchronize explain. */
	private JLabel twoWaySyncExplain;
	
	/** The auto synchronize setup. */
	private JCheckBox autoSyncSetup;
	
	/** The one way synchronize */
	private JRadioButton oneWaySync;
	
	/** The two way synchronize */
	private JRadioButton twoWaySync;
	
	/** The buttom group. */
	private ButtonGroup buttonGroup;
	
	/** The local synchronize folder. */
	private JLabel localSyncFolder;
	
	/** The server synchronize folder. */
	private JLabel serverSyncFolder;
	
	/** The local synchronize folder field. */
	private JTextField localSyncFolderField;
	
	/** The server synchonize folder field. */
	private JTextField serverSyncFolderField;
	
	/** The local synchronize direcotry choose. */
	private JButton localsyncDirectoryChoose;
	
	/** The server synchronize direcotry choose. */
	private JButton serversyncDirectoryChoose;
	
	/** The save button. */
	private JButton saveButton;
	
	/**
	 * The constructor.
	 */
	public SyncSetupsPanel()
	{
		baseImage = Design.COMPONENT_SYNCHRONIZE;
		
		this.setPreferredSize(new Dimension(750, 500));
		this.setLayout(null);
		
		setComponents();
	}
	
	/**
	 * Sets up the components and adds it to the panel.
	 */
	public void setComponents()
	{
		autoSyncSetup = new JCheckBox("Enable automatic synchronization");
		autoSyncSetup.setSize(300, 30);
		autoSyncSetup.setLocation(125, 120);
		autoSyncSetup.setForeground(Color.WHITE);
		autoSyncSetup.setFont(new Font("Arial", Font.BOLD, 12));
		
		oneWaySync = new JRadioButton("One-way file synchronization");
		oneWaySync.setSize(300, 30);
		oneWaySync.setLocation(150, 145);
		oneWaySync.setForeground(Color.WHITE);
		oneWaySync.setFont(new Font("Arial", Font.BOLD, 12));
		
		oneWaySyncExplain = new JLabel("<HTML>In one-way file synchronization, updated files are copied from server <BR>to one or more client locations, but no files are copied back to server.</HTML>");
		oneWaySyncExplain.setSize(400, 30);
		oneWaySyncExplain.setLocation(193, 170);
		oneWaySyncExplain.setForeground(Color.ORANGE);
		oneWaySyncExplain.setFont(new Font("Arial", Font.BOLD, 12));
		
		twoWaySync = new JRadioButton("Two-way file synchronization");
		twoWaySync.setSize(300, 30);
		twoWaySync.setLocation(150, 200);
		twoWaySync.setForeground(Color.WHITE);
		twoWaySync.setFont(new Font("Arial", Font.BOLD, 12));
		
		twoWaySyncExplain = new JLabel("<HTML>In two-way file synchronization, updated files are copied in both <BR>directions, to keep the two locations identical to each other.</HTML>");
		twoWaySyncExplain.setSize(400, 30);
		twoWaySyncExplain.setLocation(193, 225);
		twoWaySyncExplain.setForeground(Color.ORANGE);
		twoWaySyncExplain.setFont(new Font("Arial", Font.BOLD, 12));
	
		localSyncFolder = new JLabel("Local sync folder");
		localSyncFolder.setSize(300, 30);
		localSyncFolder.setLocation(125, 260);
		localSyncFolder.setForeground(Color.WHITE);
		localSyncFolder.setFont(new Font("Arial", Font.BOLD, 12));
		
		localSyncFolderField = new JTextField();
		localSyncFolderField.setSize(400, 26);
		localSyncFolderField.setLocation(150, 285);
		localSyncFolderField.setEditable(false);
		
		localsyncDirectoryChoose = new JButton("...");
		localsyncDirectoryChoose.setSize(30, 27);
		localsyncDirectoryChoose.setLocation(560, 285);
		
		serverSyncFolder = new JLabel("Server sync folder");
		serverSyncFolder.setSize(300, 30);
		serverSyncFolder.setLocation(125, 315);
		serverSyncFolder.setForeground(Color.WHITE);
		serverSyncFolder.setFont(new Font("Arial", Font.BOLD, 12));
		
		serverSyncFolderField = new JTextField();
		serverSyncFolderField.setSize(400, 26);
		serverSyncFolderField.setLocation(150, 340);
		serverSyncFolderField.setEditable(false);
		
		serversyncDirectoryChoose = new JButton("...");
		serversyncDirectoryChoose.setSize(30, 27);
		serversyncDirectoryChoose.setLocation(560, 340);
		
		saveButton = new JButton("Save");
		saveButton.setSize(150, 40);
		saveButton.setLocation(290, 380);
		
		buttonGroup = new ButtonGroup();
		buttonGroup.add(oneWaySync);
		buttonGroup.add(twoWaySync);
		
		this.add(autoSyncSetup);
		this.add(oneWaySync);
		this.add(oneWaySyncExplain);
		this.add(twoWaySync);
		this.add(twoWaySyncExplain);
		this.add(localSyncFolder);
		this.add(localSyncFolderField);
		this.add(localsyncDirectoryChoose);
		this.add(serverSyncFolder);
		this.add(serverSyncFolderField);
		this.add(serversyncDirectoryChoose);
		this.add(saveButton);
	}
	
	/**
	 * The overrided paintComponent.
	 */
	protected void paintComponent(Graphics g)
	{
		g.drawImage(baseImage, 0, 0, null);
	}
	
	/**
	 * Gets the auto synchronize setup.
	 * @return the auto synchronize setup.
	 */
	public JCheckBox getAutoSyncSetup()
	{
		return autoSyncSetup;
	}
	
	/**
	 * Get the one way synchronizeation.
	 * @return the one way synchronizeation.
	 */ 
	public JRadioButton getOneWaySync()
	{
		return oneWaySync;
	}
	
	/**
	 * Get the two way synchronizeation.
	 * @return the two way synchronizeation.
	 */
	public JRadioButton getTwoWaySync()
	{
		return twoWaySync;
	}
	
	/**
	 * Gets the local synchronized folder field.
	 * @return the local synchronized folder field.
	 */
	public JTextField getLocalSyncFolderField()
	{
		return localSyncFolderField;
	}
	
	/**
	 * Gets the server synchronized folder field.
	 * @return the server synchronized folder field.
	 */
	public JTextField getServerSyncFolderField()
	{
		return serverSyncFolderField;
	}
	
	/**
	 * Gets the local directory choose.
	 * @return the local directory choose.
	 */
	public JButton getLocalsyncDirectoryChoose()
	{
		return localsyncDirectoryChoose;
	}
	
	/**
	 * Gets the server directory choose.
	 * @return the server directory choose.
	 */
	public JButton getServersyncDirectoryChoose()
	{
		return serversyncDirectoryChoose;
	}
	
	/**
	 * Gets the save button.
	 * @return the save button.
	 */
	public JButton getSaveButton()
	{
		return saveButton;
	}
}